package cn.simple.manager.todo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
@Transactional
public class RepositoryTodoService implements TodoCrudService {
    @Autowired
    JdbcTemplate jdbcTemplate;


    @Override
    public List<Map<String, Object>> select(String sql) {
        return jdbcTemplate.queryForList(sql);
    }

    @Transactional
    @Override
    public int update(String sql) {
        return jdbcTemplate.update(sql);
    }

    @Transactional
    @Override
    public void insert(String sql) {
        jdbcTemplate.execute(sql); 
    }

    @Transactional
    @Override
    public int delete(String sql) {
        return  jdbcTemplate.update(sql);
    }


}
